package com.fj.order;

import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
import org.apache.rocketmq.client.apis.producer.Producer;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @author fj
 * @date 2024/3/12 00:26
 */
@SpringBootApplication
@EntityScan(basePackages = "com.fj.domain")
@EnableDiscoveryClient
@EnableFeignClients
@EnableAutoDataSourceProxy //seata必须
public class OrderApplication {
    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class,args);
    }

    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate(RestTemplateBuilder builder){
        return builder.build();
    }

//    @Bean
//    public RocketMQTemplate getRocketMQTemplate(DefaultMQProducer producer){
//        RocketMQTemplate rocketMQTemplate = new RocketMQTemplate();
//        rocketMQTemplate.setProducer(producer);
//        return rocketMQTemplate;
//    }
}
